package sg.edu.nus.dbd.util;

import java.util.logging.Level;
import java.util.logging.Logger;

public class MyLogger {

	// This boolean flag switch on/off the output of debug messages
	private static boolean debugOn = true;

	// Output a debug message to the console
	public static void debug(Class className, String message) {
		if (debugOn) {
			Logger.getLogger(className.getName()).log(Level.INFO, message);
		}
	}

	public static void debug(String message) {
		if (debugOn) {
			Logger.getLogger(MyLogger.class.getName()).log(Level.INFO, message);
		}
	}

	public static void error(Class className, Throwable exp) {
		Logger.getLogger(className.getName()).log(Level.SEVERE,
				"Exception occur", exp);
	}

	// Set the debug flag
	public static void setDebug(boolean mode) {
		debugOn = mode;
	}
}
